package com.nexgo.data.repository;

import com.nexgo.data.ChannelType;
import com.nexgo.domain.repository.PaymentPlatform;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by xiaox on 2017/12/18.
 */

public class PaymentFactory {
    public static PaymentPlatform getInstance(ChannelType type, String host, int port, int timeout) {
        PaymentPlatform paymentPlatform = null;
        switch (type) {
            case HTTPS:
                paymentPlatform = new HttpsPayment(host, port, timeout);
                break;
            case SOCKET:
            default:
                paymentPlatform = new SocketPayment(host, port, timeout);
                break;
        }
        return paymentPlatform;
    }

    //lr add解析域名
    public static String DnsProcess(String url){

        InetAddress x = null;
        try {
            x = InetAddress.getByName(url);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        String ip_devdiv = x.getHostAddress();//得到字符串形式的ip地址

        return ip_devdiv;

    }
}
